package com.zkthink.ceres.finance.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import com.zkthink.base.entity.Entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
import static com.zkthink.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

/**
 * <p>
 * 实体类
 * 流水明细表
 * </p>
 *
 * @author vivi.huang
 * @since 2020-05-26
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("ceres_journal_detail")
@ApiModel(value = "JournalDetail", description = "流水明细表")
@AllArgsConstructor
public class JournalDetail extends Entity<Long> {

    private static final long serialVersionUID = 1L;

    /**
     * 商家编码
     */
    @ApiModelProperty(value = "商家编码")
    @TableField("tenant_code")
    private String tenantCode;

    /**
     * 收支类型 1：收入，2：支出
     */
    @ApiModelProperty(value = "收支类型 0：收入，1：支出")
    @TableField("payment_type")
    @Excel(name = "收支类型 0：收入，1：支出")
    private Integer paymentType;

    /**
     * 流水类型 1：订单入账，2：买家退款，3：提现
     */
    @ApiModelProperty(value = "流水类型 1：订单入账，2：买家退款，3：提现")
    @TableField("journal_type")
    @Excel(name = "流水类型 1：订单入账，2：买家退款，3：提现")
    private Integer journalType;

    /**
     * 订单Id
     */
    @ApiModelProperty(value = "订单Id")
    @Length(max = 200, message = "订单Id长度不能超过200")
    @TableField(value = "order_code", condition = LIKE)
    @Excel(name = "订单Id")
    private String orderCode;

    /**
     * 入账时间
     */
    @ApiModelProperty(value = "入账时间")
    @TableField("entry_time")
    @Excel(name = "入账时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime entryTime;

    /**
     * 金额
     */
    @ApiModelProperty(value = "金额")
    @TableField("amount")
    @Excel(name = "金额")
    private Long amount;

    /**
     * 余额
     */
    @ApiModelProperty(value = "余额")
    @TableField("balance")
    @Excel(name = "余额")
    private Long balance;


    @Builder
    public JournalDetail(Long id, Long createUser, LocalDateTime createTime, Long updateUser, LocalDateTime updateTime, 
                    Integer paymentType, Integer journalType, String orderCode, LocalDateTime entryTime, Long amount, Long balance) {
        this.id = id;
        this.createUser = createUser;
        this.createTime = createTime;
        this.updateUser = updateUser;
        this.updateTime = updateTime;
        this.paymentType = paymentType;
        this.journalType = journalType;
        this.orderCode = orderCode;
        this.entryTime = entryTime;
        this.amount = amount;
        this.balance = balance;
    }

}
